package com.rmfyzxfw.caseprocess.model.dynamic.condition;

import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author long@flyfox
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ConditionIN implements DynamicCondition {

    private String field;
    private List<?> inValues;

    @Override
    public String generateSqlCondition() {
        if (CollectionUtils.isNotEmpty(inValues)) {
            return field + " IN (" + inValues.stream().map(Object::toString).collect(Collectors.joining(",")) + ")";
        }
        return null;
    }
}

